package com.wjy.sfhcore.engine;

import android.os.AsyncTask;

import com.wjy.sfhcore.itf.OnPostResultListener;
import com.wjy.sfhcore.util.DataUtil;

import java.util.Map;

/**
 * 
 * @author wjy
 * 
 * @param <D>
 */
public abstract class BaseAsyncTask<D> extends AsyncTask<String, Integer, D> {
	protected OnPostResultListener<D> resultListener;
	protected DataUtil mDataUtil = new DataUtil();
	protected Map<String, String> params;

	public BaseAsyncTask(OnPostResultListener<D> resultListener) {
		this.resultListener = resultListener;
		params = BaseParams.getInstance().getBaseParams();
	}

	protected abstract D doInBackground(String... url);

	protected void onPostExecute(D result) {
		if (isCancelled()) {
			return;
		}
		if (resultListener != null) {
			resultListener.onPostResult(result);
		}
	}
}
